﻿using SelfMadeMillionaire.Core.Entities;
using SelfMadeMillionaire.Core.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SelfMadeMillionaire.DAL.Repositories
{
	public class EmailMessageRepository : Repository<EmailMessage>, IEmailMessageRepository
	{
		public EmailMessageRepository(IUnitOfWork uow)
			: base(uow)
		{
		}

		public void AddSubscriber(Subscriber subscriber)
		{
			_uow.GetDbSet<Subscriber>().Add(subscriber);
			_uow.Commit();
		}

		public Subscriber GetSubscriber(string email)
		{
			return _uow.GetDbSet<Subscriber>().SingleOrDefault(x => x.Email == email);
		}

		public IEnumerable<Subscriber> GetSubscribers()
		{
			return _uow.GetDbSet<Subscriber>();
		}


		public Subscriber GetSubscriber(int id)
		{
			return _uow.GetDbSet<Subscriber>().Single(x => x.ID == id);
		}
	}
}
